interface INode {
    (x: number): number;
}
interface INodes {
    (x: number[]): number[];
}
let index = 0;
let weights: { [key: number]: number } = {}
function weight(id: number) {
}
function node(): INode {
    let px: number = 0;
    let w: number = 1;
    let b: number = 0;
    let id = ++index;
    return (x: number) => {
        const y = x * w + b;
        b = x - px;
        w = weights[id] || 1;
        px = x;
        return y;
    }
}
function nodes(): INodes {
    const list: INode[] = [];
    return (x: number[]) => {
        x = x.filter(i => i !== 0)
        if (x.length <= nodes.length) {
            return x.map((v, i) => list[i](v))
        } else {
            while (x.length > nodes.length) {
                list.push(node());
            }
            return x.map((v, i) => list[i](v))
        }
    }
}

function nodess() {
    const list: INodes[] = [];
    return (x: number[][]) => {
        if (x.length <= nodes.length) {
            return x.map((v, i) => list[i](v))
        } else {
            while (x.length > nodes.length) {
                list.push(nodes());
            }
            return x.map((v, i) => list[i](v))
        }
    }
}
const n = node();
import { createInterface } from 'readline'
const i = createInterface({
    input: process.stdin,
    output: process.stdout
})
async function run() {
    while (true) {
        await new Promise<void>((resolve, reject) => {
            i.question(`输入:`, (v) => {
                const x = parseFloat(v)
                const y = n(x)
                i.question(`结果：`, v => {
                    const y1 = parseFloat(v)
                    // 更新weight
                    console.log({ y, y1, x })
                    resolve()
                })
            })
        })
    }
}
run()

